<template>
  <!-- 海报位组件属性 -->
  <div class="posterAttr">
    <div class="comInfo">
      <div class="item1">
        <div class="label">位置：</div>
        <div class="item">
          <div class="infoCon">
            <div class="con" style="margin-right:20px;">
              <span>x：</span>
              <el-input v-model.number="list.style.x" :disabled="ispreview"></el-input>
            </div>
            <div class="con">
              <span>y：</span>
              <el-input v-model.number="list.style.y" :disabled="ispreview"></el-input>
            </div>
          </div>
        </div>
      </div>
      <div class="item1">
        <div class="label">大小：</div>
        <div class="item">
          <div class="infoCon">
            <div class="con" style="margin-right:20px;">
              <span>w：</span>
              <el-input v-model.number="list.style.w" :disabled="ispreview"></el-input>
            </div>
            <div class="con">
              <span>h：</span>
              <el-input v-model.number="list.style.h" :disabled="ispreview"></el-input>
            </div>
          </div>
          <div id="tipMsg" style="marginLeft:25px;color:red;display:none;">组件最大宽度为1133px</div>
        </div>
      </div>
      <div class="item1">
        <div class="label">楼层名称：</div>
        <div class="item">
          <div class="infoCon">
            <el-input v-model.number="list.floorName" :disabled="ispreview"></el-input>
          </div>
        </div>
      </div>
      <div class="item1">
        <div class="label">楼层编码：</div>
        <div class="item">
          <div class="infoCon">
            <el-input v-model.number="list.floorNum" :disabled="ispreview"></el-input>
          </div>
        </div>
      </div>
      <div class="item1">
        <div class="label">焦点位置：</div>
        <div class="item">
          <div class="infoCon">
            <el-input v-model.number="list.value[0].index" :disabled="ispreview"></el-input>
          </div>
          <div id="tipMsg1" style="color:red;display:none;">焦点位置：不能为0，最小从1开始</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'posterAttr',
  components: {},
  props: {
    comData: {
      type: Object,
      default: () => {}
    },
    ispreview:{
      type:Boolean,
      default: false
    }
  },
  data() {
    return {
      list: this.comData,
    }
  },
  watch:{
    'list.style':{
      handler(val){
        if(val.w > 1133){
          // this.$message.error('组件宽度最大为1133');
          document.getElementById('tipMsg').style.display = 'block';
          setTimeout(() =>{
            document.getElementById('tipMsg').style.display = 'none';
            this.list.style.w = 1133;
            this.list.style.x = 4;
            this.list.style.y = 5;
          },2000)
        } 
      },
      deep: true,
    },
    'list.value':{
      handler(val){
        if(val[0].index == 0){
          // this.$message.error('位置排序不能为0，至少从1开始');
          document.getElementById('tipMsg1').style.display = 'block';
          setTimeout(() =>{
            document.getElementById('tipMsg1').style.display = 'none';
            this.list.value[0].index = 1;
          },2500)
        }
      },
      deep: true,
    }
  },
  methods: {
    
  }
}
</script>

<style lang="less" scoped>
.posterAttr{
  .comInfo{
    margin: 10px 5px;
    .item1{
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      padding: 10px;
      border-bottom: 1px dashed #dbdbdb;
      .label{
        width: 80px;
      }
      .item{
        width: calc(100% - 80px);
      }
      .infoCon{
        display: flex;
        align-items: center;
        flex-direction: row;
        justify-content: flex-start;
        .con{
          display: flex;
          align-items: center;
          span{
            width: 25px;
          }
        }
      }
    }
  }
}
</style>